package com.example.welcome;

import android.animation.Animator;
import android.animation.AnimatorListenerAdapter;
import android.animation.AnimatorSet;
import android.animation.ObjectAnimator;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.widget.TextView;

public class Main2Activity extends AppCompatActivity {
    TextView textView;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main2);
        textView = (TextView) findViewById(R.id.helloworld);
        final AnimatorSet set=new AnimatorSet();
        ObjectAnimator translationY=ObjectAnimator.ofFloat(textView,"translationY",0,300);
//代表自身顺时针旋转从0度旋转360度
        ObjectAnimator rotation=ObjectAnimator.ofFloat(textView,"rotation",0,360);
//代表沿X轴从0度旋转360度
        ObjectAnimator rotationX=ObjectAnimator.ofFloat(textView,"rotationX",0,360);
//设置动画的时长，2000代表在2秒内完成
        set.setDuration(3000);
//把动画放到AnimatorSet 中
        set.playTogether(translationY,rotation,rotationX);
//执行动画
        set.start();
        set.addListener(new AnimatorListenerAdapter() {
            @Override
            public void onAnimationEnd(Animator animation) {
                super.onAnimationEnd(animation);
                set.start();
            }
        });
    }
}
